int days_in_month(int month, int year)
{
	switch(month)
	{
	case 4:
	case 6:
	case 9:
	case 11:
		return 30;
	case 2:
		return ((year % 4) == 0) ? 29 : 28;
	default:
		return 31;
	}
}

int day_of_week(int days, int month, int year)
{
	int i;
	int total=5;

	for(i=0;i<year;i++)
		total += ((i % 4) == 0) ? 366 : 365;

	for(i=1;i<month;i++)
		total += days_in_month(i,year);
	total+=days;

	return total % 7;

}
